#-IMPORTS-----------------------------------------------------------------------
import logging
#-CONSTANTS---------------------------------------------------------------------
SSH_CMD = 'ssh'
#-CLASSES-----------------------------------------------------------------------
class CmdFactory:
      def __init__(self):
        self.__log = logging.getLogger(__name__)
        self.__commands = {}

      def register(self, p_cmdName, p_class):
          self.__commands[p_cmdName] = p_class
          self.__log.debug('(%s) added to the command factory.'%p_cmdName)

      def getCmd(self, p_cmdName, p_params):
          """If this method is called then the requested command have already
          been verified as a valid command so we default to an ssh command.
          """
          if self.__commands.has_key(p_cmdName):
              return self.__commands[p_cmdName](p_params)
          return self.__commands[SSH_CMD](p_params)
